<?php
namespace Amis\form;
class InputRichText extends FormItem
{
    public string $type = 'input-rich-text';

    /**
     * 是否保存为 ubb 格式
     * @param bool $saveAsUbb
     * @return $this
     */
    public function saveAsUbb(bool $saveAsUbb)
    {
        $this->saveAsUbb = $saveAsUbb;
        return $this;
    }

    /**
     * 默认的图片保存 API
     * @param string $receiverApi
     * @return $this
     */
    public function receiver(string $receiverApi)
    {
        $this->receiver = $receiverApi;
        return $this;
    }

    /**
     * 默认的视频保存 API
     * @param string $videoReceiver
     * @return $this
     */
    public function videoReceiver(string $videoReceiver)
    {
        $this->videoReceiver = $videoReceiver;
        return $this;
    }

    /**
     * 上传文件时的字段名
     * @param string $fileField
     * @return $this
     */
    public function fileField(string $fileField)
    {
        $this->fileField = $fileField;
        return $this;
    }

    /**
     * 框的大小，可设置为 md 或者 lg
     * @param string $size
     * @return $this
     */
    public function size(string $size)
    {
        $this->size = $size;
        return $this;
    }

    /**
     * 需要参考 tinymce 或 froala 的文档
     * https://www.froala.com/wysiwyg-editor/docs/options
     * https://www.tiny.cloud/docs/configure/integration-and-setup/
     * @param $options
     * @return $this
     */
    public function options($options)
    {
        $this->options = $options;
        return $this;
    }

    /**
     * froala 专用，配置显示的按钮，tinymce 可以通过前面的 options 设置 toolbar 字符串
     * @param $buttons
     * @return $this
     */
    public function buttons($buttons)
    {
        $this->buttons = $buttons;
        return $this;
    }
}